describe("AdminUserListingModel", ()->
    listingModel = null;
    beforeEach(()->
      @server = sinon.fakeServer.create();
      listingModel = new AdminUserListingModel();
      listingModel.set("Page",1);
      listingModel.set("Size",10);
      listingModel.set("Column","Email");
      listingModel.set("Direction",1);
      listingModel.set("Filter":{"Email": "TestEmail", "Login":"TestLogin"})
    );

    afterEach(()->
       @server.restore();
    );

    it("Listing model should has valid url", ()->


      expect(listingModel.url()).toEqual(SiteMap.Admin.Users.Listing+"?page=1&size=10&Column=Email&Direction=1&Filter.Email=TestEmail&Filter.Login=TestLogin");
    )

    it("Listing model should has valid parse features", ()->
      @server.respondWith("GET",
      SiteMap.Admin.Users.Listing+"?page=1&size=10&Column=Email&Direction=1&Filter.Email=TestEmail&Filter.Login=TestLogin",
      [200, { "Content-Type": "application/json" },
      '{ "Filter":{"Email":"megaEmail","Login":"megaLogin"},"Page": 2, "Size":15, "TotalPages": 10,"Direction":0,"Column":"Login","Users":[{"UserId":1}, {"UserId":2}]}']);

      listingModel.fetch();
      @server.respond();

      expect(listingModel.get("Page")).toEqual(2);
      expect(listingModel.get("Size")).toEqual(15);
      expect(listingModel.get("TotalPages")).toEqual(10);
      expect(listingModel.get("Direction")).toEqual(0);
      expect(listingModel.get("Column")).toEqual("Login");
      expect(listingModel.get("Filter")).toEqual({Email:"megaEmail",Login:"megaLogin"});
      expect(listingModel.get("Users").length).toEqual(2);

    )
);

describe("AdminUserEditModel", ()->
    editModel = null;
    beforeEach(()->
      @server = sinon.fakeServer.create();
      editModel = new AdminUserEditModel();
      editModel.set("UserId",1);
    );

    afterEach(()->
       @server.restore();
    );

    it("Edit model should has valid url", ()->
          expect(editModel.url()).toEqual(SiteMap.Admin.Users.Edit+"?userId=1");
    )

    it("Edit model should has valid parse features", ()->
      @server.respondWith("GET",
      SiteMap.Admin.Users.Edit+"?userId=1",
      [200, { "Content-Type": "application/json" },
      '{ "Email":"megaEmail","Login":"megaLogin","Status": 2, "Avatar":"TestAvatar"}']);

      editModel.fetch();
      @server.respond();

      expect(editModel.get("Email")).toEqual("megaEmail");
      expect(editModel.get("Login")).toEqual("megaLogin");
      expect(editModel.get("Status")).toEqual(2);
      expect(editModel.get("Avatar")).toEqual("TestAvatar");

    )
);